<template>
    <div class="header">
        <div class="header_cont pointer">
            <div class="logo" @click="returnHome">
                <img src="@/assets/img/logo.png" class="mr" />
                <img src="@/assets/img/header_line.png" class="mt" />
            </div>
            <div class="title">电力创新奖申报平台</div>
            <div class="header_right pointer" @click="toLogin" v-if="page == 'register'">
                <span>已有账号，现在登录</span>
            </div>
        </div>
        <div class="top_menu" v-if="page == 'login'">
            <a-menu v-model="current" mode="horizontal">
                <a-menu-item>
                    <a @click="toLogin">成果申报</a>
                </a-menu-item>
                <a-menu-item>
                    <a @click="toResult()">已报成果</a>
                </a-menu-item>
                <a-menu-item>
                    <a @click="toFsdb()">复审答辩</a>
                </a-menu-item>
                <a-menu-item>
                    <a @click="toUserCenter()">用户中心</a>
                </a-menu-item>
                <!-- <a-menu-item>
                  <a @click="appealAgainstFn()">我要申诉</a>
              </a-menu-item> -->
            </a-menu>
        </div>
        <div class="top_menu" v-else>
            <a-menu v-model="current" mode="horizontal">
                <a-menu-item key="gwsy">
                    <a href="https://www.cec.org.cn/" target="_blank">官网首页</a>
                </a-menu-item>
                <a-menu-item key="ptsy">
                    <a @click="toIndex">平台首页</a>
                </a-menu-item>
                <a-menu-item key="tzgg">
                    <a @click="alterTzgg()">通知公告</a>
                </a-menu-item>
                <a-menu-item key="zlzx">
                    <a @click="alterZlzx()">资料中心</a>
                </a-menu-item>
                <!-- <a-menu-item key="zlzx">
                  <a @click="alterZlzx()">获奖成果查询</a>
              </a-menu-item> -->
            </a-menu>
        </div>
    </div>
</template>

<script>
import {
    cxjsbPageList,
    sysCxjZlList,
    sysCxjZlDownload
} from '@/api/shenbao'
export default {
    inject: ['reload'],
    data() {
        return {
            isHead: null,
            current: ['ptsy'],
            navInd: '',
            leftNav: [{
                title: "通知公告",
                id: 0
            }, {
                title: "资料中心",
                id: 1
            }],
            dataList: [],
            zlList: [],
            total: 0,
            loginstatus: '',
            key: ''
        }
    },
    props: ['page'],
    mounted() {
        this.isHead = sessionStorage.getItem('isHead')
        console.log('afdasfasdfasdfasdfsdfsdfasdfasdfasdf', this.isHead)
        this.navInd = this.$route.query.ind;
        this.getList();
        this.getZlList();
        var islogin = sessionStorage.getItem('islogin');
        if (islogin == '1') {
            this.loginstatus = 'login';
        } else {
            this.loginstatus = 'unlogin';
        }
    },
    methods: {
        toResult() {
            this.$router.push('/shenbao/result');
        },
        toFsdb() {
            this.$router.push('/shenbao/fsdb');
        },
        toUserCenter() {
            this.$router.push('/shenbao/userCenter');
        },
        appealAgainstFn() {
            this.$router.push('/shenbao/appealAgainst');
        },
        toLogin() {
            this.$router.push('/shenbao/login');
        },
        returnHome() {
            this.$router.push('/shenbao/login')
        },
        toIndex() {
            this.$router.push('/shenbao/entrance')
            // this.current = 'ptsy'
            this.current = ['ptsy']
        },
        alterTzgg() {
            this.reload()
            this.$router.push('/shenbao/articleList?ind=0')
        },
        alterZlzx() {
            this.reload()
            this.$router.push('/shenbao/articleList?ind=1')

        },
        handelChange(index) {
            this.navInd = index;
        },
        // 获取申报列表
        getList() {
            let data = {
                pageNo: 1,
                pageSize: 10
            }
            cxjsbPageList(data).then(res => {
                if (res.data.success) {
                    this.dataList = res.data.result.records;
                    this.total = res.data.result.total;
                }
            })
        },
        // 跳转详情
        viewDetail(id) {
            this.$router.push({
                path: '/shenbao/innovationAwardNotice',
                query: {
                    id
                }
            })
        },
        // 获取资料中心列表
        getZlList() {
            let data = {
                pageNo: 1,
                pageSize: 10
            }
            sysCxjZlList(data).then(res => {
                if (res.data.success) {
                    this.zlList = res.data.result.records;
                    this.total = res.data.result.total;
                }
            })
        },
        downloadZl(url, zlMc) {
            let that = this;
            let fileGs = url.split('.');
            sysCxjZlDownload(url).then(res => {
                that.downfn(zlMc, res, fileGs[1]);
            })
        },
        downfn(title, res, fileGs) {
            const data = res.data;
            const url = window.URL.createObjectURL(new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }))
            const link = document.createElement('a')
            link.style.display = 'none'
            link.href = url;
            link.setAttribute('download', title + '.' + fileGs)
            document.body.appendChild(link)
            link.click()
            document.body.removeChild(link)
        }
    },
    mounted() {
        // console.log(this.page)
    }
}
</script>
<style lang="less" scoped>
.header {
    width: 100%;
    height: 144px;
    position: relative;
    background-color: #ffffff;
    background-image: url("../../../assets/img/toparea.png");
}

.header_cont {
    width: 1400px;
    margin: 0 auto;
    position: relative;
    top: 15px;
    display: flex;
    overflow: hidden;

    .logo {
        display: flex;
        align-items: flex-start;
    }

    .mr {
        margin-right: 20px;
        height: 70px;
    }

    .mt {}

    .title {
        font-size: 30px;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        color: #0a4174;
        line-height: 50px;
        margin-left: 20px;
        padding-top: 10px;
        box-sizing: border-box;
        font-weight: 500;
    }
}

.header_right {
    position: absolute;
    right: 0;
    top: 20px;

    span {
        height: 30px;
        font-size: 18px;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-weight: 400;
        color: #0840b1;
        line-height: 30px;
    }
}

.user_right {
    position: absolute;
    right: 0;
    top: -25px;
    display: flex;

    p {
        width: 100px;
        height: 120px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        &.active {
            background: #1462b3;

            span {
                color: #ffffff;
            }
        }

        img {
            width: 34px;
            height: 34px;
        }

        span {
            margin-top: 10px;
            font-size: 16px;
            font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
            font-weight: 500;
            color: #1462b3;
            line-height: 22px;
        }
    }
}

p {
    margin: 0;
}

.top_menu {
    background-image: url("../../../assets/img/bar.png");
    position: relative;
    display: flex;
    top: 26px;
    height: 49px;

    ul {
        width: 1200px;
        margin: 0 auto;
    }

    .ant-menu-horizontal {
        background-image: url("../../../assets/img/bar.png");
        border-bottom: none;
    }

    .ant-menu-horizontal>.ant-menu-item>a {
        color: #ffffff;
        font-size: 17px;
        letter-spacing: 2px;
        font-weight: 400;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-stretch: 100%;
        text-size-adjust: 100%;
    }

    .ant-menu-horizontal>.ant-menu-item:hover,
    .ant-menu-horizontal>.ant-menu-item-selected {
        background-image: url("../../../assets/img/select.png");
        border-bottom: none;
    }

    .ant-menu-item,
    .ant-menu-submenu-title {
        padding: 0px 43px;
    }

    .zdl-menu-bar-group-item:hover {
        background: url("../../../assets/img/select.png") center center no-repeat;
        background-size: 100% 49px;
    }
}
</style>
